Xbasic

json_standardize Function

Syntax

json_standardize(json as C [,flagReformat as L ])

Arguments

jsonCharacter

A string containing the JSON to standardize.

flagReformatLogical

Default is .t.. Reformats the JSON if .t.. Otherwise, doesn't modify the JSON formatting.

Description

JSON_standardize function takes a non-standard JSON string and standardizes it. It also corrects for trailing commas in the JSON (which are illegal). Returns the standardized JSON.

Example

?json_standardize("{name: 'Fred', age: 21}")
= {
    "name": "Fred",
    "age": 21
}

' Standardize the JSON, but don't change the formatting:
?json_standardize("{name: 'Fred', age: 21,}",.f.)
= {"name":"Fred","age":21}

See Also